package com.xuzhijie.pms.entity.vo;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.xuzhijie.pms.entity.Property;
import com.xuzhijie.pms.entity.Vehicle;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;

@Data
@ToString
public class VehicleVo {
    private String id;
    /**
     * 车牌号码
     */
    private String licensePlateNumber;

    /**
     * 汽车绑定的房产
     */
    private String propertyVehicleBinding;

    /**
     * 车辆类型，七座及以下小客车/小型货车1；七座以上客车/中大型货车
     */
    private Integer vehicleCategory;

    /**
     * 是否是新能源
     */
    private Integer isNewEnergy;

    /**
     * 绑定状态
     */
    private Integer isBinding;

    /**
     * 同步状态
     */
    private Integer syncStatus;

    private Integer version;

    @TableLogic
    private Integer isdelete;

    private LocalDateTime createTime;

    private String master;

    private String remark;

    private String[] images;
    public VehicleVo(Vehicle vehicle){

        if (vehicle.getImages() != null) {
            String str = vehicle.getImages();
            str = StrUtil.removePrefix(str, "[");
            str = StrUtil.removeSuffix(str, "]");
            // 使用逗号和空格作为分隔符拆分字符串
            List<String> split = StrUtil.split(str, ",");
            String[] strings = new String[split.size()];
            for (int i = 0; i < split.size(); i++) {
                strings[i] = split.get(i);
            }
            this.images = strings;
        }
    }

}
